function [T]=showRobustWeightsTmatrix(TF,w,h,numparams,corrs,type)

mscale=30;
numparmvariable=5; % oscilating all variables
[~,numFs]=size(TF);

xstart=w/2;
ystart=h/2;
fstart=w;

numTries=6000;
Weights=0




T=zeros(numTries,numFs);

fstd=1;
xstd=xstart/200;
ystd=ystart/200;
skewstd=0.01;
arstd=0.01;


fstd=fstd* mscale;
xstd=xstd* mscale;
ystd=ystd* mscale;
skewstd=skewstd* mscale;
arstd=arstd* mscale;

for i=1:numTries
    focal=fstart+(randn()*fstd);
    ar=(1+rand()*arstd);
    skew=skewstd*randn();
    xguess=xstart+(randn()*xstd);
    yguess=ystart+(randn()*ystd);
    Kguess = [focal   skew        xguess;   0      focal*ar   yguess;   0            0             1  ];
    
    Kng=convertXTOKselfK(convertKTOXselfK(Kguess,numparmvariable),w,h);
    
    focal=fstart+(randn()*fstd);
    ar=(1+rand()*arstd);
    skew=skewstd*randn();
    xguess=xstart+(randn()*xstd);
    yguess=ystart+(randn()*ystd);
    Kguess = [focal   skew        xguess;   0      focal*ar   yguess;   0            0             1  ];
    
    Kng2=convertXTOKselfK(convertKTOXselfK(Kguess,numparmvariable),w,h);
    
    for j=1:numFs
        
        [T(i,j),~,~] = computerEssentialErrorSVDparts(TF{1,j},Kng,Kng2');
        
    end
    
end

leg=cell(1,numFs);
for j=1:numFs
    leg{1,j}=['F(' num2str(j) ')'];
%     histfit(T(:,j));
%     title(leg{1,j});
%     figure
   x= HartleySelfHouman( TF{1,j},w,h );
   display([leg{1,j} ' had Fs ' num2str(x(1,1)) ' and ' num2str(x(1,2)) ' according to hartley']);
end

hist(T);
legend(leg);
s=std(T);
m=mean(T);
Tv=cov(T);
[R,P]=corrcoef(T);
vv=cov(T);
 rc=mean((cov(T)))';
 m'/mean(m)
 rc/mean( rc)
end

function [F,s1,s2] = computerEssentialErrorSVDparts(MYF,K1,K1T)

if(isempty(MYF)==1)
    F=0;
    return;
end

G=(K1T)*MYF*K1;

try
    S = svd(G);
catch
    S= [ 100 ;  10 ;  5];
end

if( S(2,1)>eps)
    F=(((S(1,1)-S(2,1))/S(2,1))); % should not be squared but all my thresholds are based on this being squared
else
    
    F=100;
end

s1=S(1,1);
s2=S(2,1);

end
function w = exponfunc(r)


sumt=0;
while(sumt<eps)
    w = (exp(-r));
    sumt=sum(abs(w));
    r=r/2;
end
end
%
%
function w = bisquare(r)

t= 4.685;
r=r/t;
sumt=0;
while(sumt<eps)
    w = (abs(r)<1) .* (1 - (r/1).^2).^2;
    sumt=sum(abs(w));
    r=r/2;
end
end
